package com.team.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.team.entity.Shoper;

@Repository
public class ShoperDaoImpl {
	
	@Autowired
	private SessionFactory sessionFactory;
	
	public int add(Shoper shoper){
		  int addFood=(int) this.sessionFactory.getCurrentSession().save(shoper);
	      System.out.println(shoper);
		  return 1 ;
		
	}
	
	
    public void detele(Integer id){
    	  Session session = this.sessionFactory.getCurrentSession();
   	   Shoper shoper= session.get(Shoper.class, id);
   	  
   	   session.delete(shoper);
   	  
    }
    
    public void update(Shoper shoper){
    	this.sessionFactory.getCurrentSession().update(shoper);
    }
    
    public List<Shoper> foundAll(){
    	String hql ="from Food";
    	   Query query = this.sessionFactory.getCurrentSession().createQuery(hql);
    	   List<Shoper> Flist = query.list();
    	   return Flist;
    }
}
